-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(switchLatest): make switchLatest a standalone impl, add virtual time tests #317
Conversation
benlesh
commented
Sep 16, 2015
- completely refactors switchLatest to be a standalone implementation
- adds a lot of tests around switch latest
@@ -3,15 +3,166 @@ var Rx = require('../../dist/cjs/Rx'); | |||
var Observable = Rx.Observable; | |||
var immediateScheduler = Rx.Scheduler.immediate; | |||
|
|||
describe('Observable.prototype.switchLatest()', function () { | |||
fdescribe('Observable.prototype.switchLatest()', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdescribe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Good catch.
That's to limit jasmine tests to just that grouping during development. I meant to remove that.
@@ -58,13 +66,18 @@ class SwitchSubscriber<T> extends Subscriber<T> { | |||
} | |||
|
|||
class InnerSwitchSubscriber<T> extends Subscriber<T> { | |||
constructor(destination: Observer<any>, private parent: SwitchSubscriber<T>) { | |||
super(destination); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Blesh couldn't we still set destination
on the InnerSwitchSubscriber
, but invoke super
with no argument? I believe the only logic we want to short-circuit here is the shared _subscription
assignment. Then we don't have to override _next
or _error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would probably work. If you want to make that change, feel free to PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to devote some thought to the whole shared-subscription approach and see if I can poke any more holes in it. The solution may be as simple as explicitly passing the shared subscription to Subscriber's constructor, instead of reading it off the destination. Will let you know.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |